<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@	page import="java.util.*" %> 
<%@ page import="com.gpstracking.BL.AreaBL " %>   
<%@ page import="com.gpstracking.BE.Area" %>
<%@ page import="com.gpstracking.BL.RutaBL " %>   
<%@ page import="com.gpstracking.BE.Ruta" %>
<%@ page import="com.gpstracking.BE.Usuario" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"> 

	<head>
		<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
		<meta charset="UTF-8" />
		<meta name="description" content="" />
		<meta name="keywords" content="" />
		<meta name="author" content="" />
		
		  <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #map_canvas { 
      	height: 400px;
      	width: 400px;
      	position: relative; 
       }
      #map_canvas2 { 
      	height: 400px;
      	width: 400px;
      	position: relative; 
       }       
    </style>
    <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyC5S9soHyeEA9TCIfxAGUo3fOqJfTh4eFk&sensor=false" type="text/javascript"></script>
    <script src="../js/geometry.js" type="text/javascript" ></script>
    <script src="../js/defAreas.js" type="text/javascript" ></script>
    <script src="http://code.jquery.com/jquery.min.js" type="text/javascript" ></script>
  
    
   
		
		<!--========= STYLES =========-->
		<link rel="stylesheet" href="../css/reset.css" />
		<link rel="stylesheet" href="../css/grid.css" />
		<link rel="stylesheet" href="../css/uniform.default.css" />
		<link rel="stylesheet" href="../css/chosen.css" />
		<link rel="stylesheet" href="../plugins/jqueryui/all/themes/base/jquery.ui.all.css" />
		<link rel="stylesheet" href="../plugins/alerts/resources/css/jquery.toastmessage.css" />
		<link rel="stylesheet" href="../plugins/datatables/media/css/demo_page.css" />
		<link rel="stylesheet" href="../plugins/datatables/media/css/demo_table_jui.css" />
		
		<link rel="stylesheet" href="../css/style.css" />
		<link rel="stylesheet" href="../css/config.css" />
		<!--[if gte IE 8]><link rel="stylesheet" href="css/ie8.css" /><![endif]-->
		
		<!--============ JQUERY =============-->
		<script src="../js/jquery.js" type="text/javascript"></script>
		
		<script src="../js/jquery.uniform.js" type="text/javascript"></script>
		<script src="../js/chosen.jquery.js" type="text/javascript"></script>
		<script src="../js/jquery.placeholder.js" type="text/javascript"></script>
		<script src="../plugins/jqueryui/all/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
		<script src="../plugins/alerts/javascript/jquery.toastmessage.js" type="text/javascript"></script>
		<script src="../js/scriptbreaker-multiple-accordion-1.js" type="text/javascript" ></script>
		<script src="../plugins/datatables/media/js/jquery.dataTables.js" type="text/javascript" ></script>
		<script src="../js/head_scripts.js" type="text/javascript"></script>
		<script src="../js/jquery.anchor.js" type="text/javascript"></script>
		<script src="../js/controller/areas.js" type="text/javascript"></script>
	
						
		<!--=== ENABLE HTML5 TAGS FOR IE ===-->
		<!--[if IE]><script src="js/html5.js"></script><![endif]-->
		
		<title>GPS Tracking</title>
	</head>
	<% 
		Usuario user = (Usuario)session.getAttribute("user");
	
		AreaBL areaController = new AreaBL();
		List<Area> areasActivas = areaController.listarAreas(user);

		RutaBL rutaController = new RutaBL();
		List<Ruta> rutasActivas = rutaController.listarRutas(user);


	
	 %>
	<body onload="initialize()">
		<jsp:include page="../static/sidebar.jsp" />
		
		
		<section class="container">
			
			<section class="container_12">
				<section id="page_content" class="page_content">
					<jsp:include page="../static/toppanel.jsp" />				
		
					<div class="grid_12">
					
						<div class="box">
							<h2>
								Areas registradas
								<span class="l"></span><span class="r"></span>
							</h2>
							<div class="block">
								<div class="block_in">
									<!-- BEGIN TABLE -->
									<table class="display basictable" >
										<thead>
											<tr>
												<th>Codigo</th>
												<th>Nombre</th>
												<th>Localización aproximada</th>
												<th>Detalle</th>
											</tr>
										</thead>
										<tbody>
											
											<% for( Area it : areasActivas) { %>
											<tr id="<% out.print( it.getIdArea() );%>">
												<td style=<% out.print(" \" color : #"+it.getColor()  +" \" "); %>>AR<% out.print(it.getIdArea()); %></td>
												<td  ><% out.print(it.getNombre()); %></td>
												<td><%out.print(it.getDescripcion());%></td>
												<td><a class="button editarArea" href="#mapas"> Editar </a></td>
											</tr>
											<% } %>
											
										</tbody>
									</table>
									<!-- END TABLE -->
								</div>
							</div>
						</div>
					</div> <!-- End of .grid_12 -->
					<div class="clear"></div>
					
					<div class="grid_12">
						<div class="box">
							<h2>
								Rutas registradas 
								<span class="l">
									
								</span>
								
								<span class="r"></span>
							</h2>
							<div class="block">
								<div class="block_in">
									<!-- BEGIN TABLE -->
									<table class="display basictable">
										<thead>
											<tr>
												<th>Codigo</th>
												<th>Nombre</th>
												<th>Localización aproximada</th>
												<th>Detalle</th>
											</tr>
										</thead>
										<tbody>
											<% for( Ruta it : rutasActivas) { %>
											<tr id="<% out.print( it.getIdRuta() );%>">
												<td style=<% out.print(" \" color : #"+it.getColor()  +" \" "); %>>RU<% out.print(it.getIdRuta()); %></td>
												<td><% out.print(it.getNombre()); %></td>
												<td><%out.print(it.getDescripcion());%></td>
												<td><a class="button editarRuta" href="#mapas"> Editar </a></td>
											</tr>
											<% } %>
										</tbody>
									</table>
									<!-- END TABLE -->
								</div>
							</div>
						</div>
					</div> <!-- End of .grid_12 -->
					<div class="clear"></div>
					
					
					<div class="grid_6" id="mapas" >
						<div class="box">
							<div class="block">
								<div class="box">
									<h2>
										<button id="btnRegistroArea" class="button">(Volver a modo registro)</button>
										&nbsp;Definir Área
										<span class="l"></span><span class="r"></span>
									</h2>
									<div class="hide"><span class="s">+</span><span class="h">-</span></div>
									<div class="block">
										<table>
										<tr>
											<td>
												<div id="map_canvas" ></div>
											</td>
											<td style="padding-left: 10 px;">
											<form class="form_place" name="registrarArea" style="width=700px" method="post" >
												<section class="form_row">
													<div class="grid_2"><label>Nombre:</label></div>
													<div class="grid_10">
														<div class="block_content">
															<input type="text" name="nombreArea" id="nombreArea" class="i-format" required="required" />
														</div>
													</div>
													<div class="clear"></div>
												</section>
											
												<section class="form_row">
													<div class="grid_2"><label>Descripción sobre la localización:</label></div>
													<div class="grid_10">
														<div class="block_content">
															<input type="text" name="descripcionArea" id="descripcionArea" class="i-format" required="required" />
														</div>
													</div>
													<div class="clear"></div>
												</section>
																							
												
												<script type="text/javascript" src="../js/jscolor/jscolor.js"></script>
												<section class="form_row">
													<div class="grid_2"><label>Color:</label></div>
													<div class="grid_10">
														<div class="block_content">
															<input class="color" i type="text" name="color" id="color" class="i-format" required="required" onchange="return changeColorArea();" value="FF3729"/>
														</div>
													</div>
													<div class="clear"></div>
												</section>
													
												<section class="form_row">
													<div class="grid_10 alignright">
															<div class="block_content">
																<button id="regArea" class="button blue medium alignleft" >
																	Registrar
																</button>
																
																<button id="modArea" class="button red medium alignleft">
																	Modificar
																</button>
																															
															</div>
													</div>
													<div class="clear"></div>
												</section>
											</form>
											</td>
										</tr>
										</table>	
									
								
									</div>
								</div>
							</div>
						</div>
					</div><!-- End of Definir arae -->
					
					
					<div class="grid_6">
						<div class="box">
							<div class="block">
								<div class="box">
									<h2>
										Definir Ruta
										<button id="btnRegistroRuta" class="button">(Volver a modo registro)</button>
										<span class="l"></span><span class="r"></span>
									</h2>
									<div class="hide"><span class="s">+</span><span class="h">-</span></div>
									<div class="block">
										<table>
										<tr>
											<td>
												<div id="map_canvas2" ></div>
											</td>
											<td style="padding-left: 10 px;">
											<form class="form_place" name="registrarRuta" style="width=700px" method="post">
												<section class="form_row">
													<div class="grid_2"><label>Nombre:</label></div>
													<div class="grid_10">
														<div class="block_content">
															<input type="text" name="nombreRuta" id="nombreRuta" class="i-format" required="required" />
														</div>
													</div>
													<div class="clear"></div>
												</section>
											
												<section class="form_row">
													<div class="grid_2"><label>Descripción sobre la ruta:</label></div>
													<div class="grid_10">
														<div class="block_content">
															<input type="text" name="descripcionRuta" id="descripcionRuta" class="i-format" required="required" />
														</div>
													</div>
													<div class="clear"></div>
												</section>
												
												<section class="form_row">
													<div class="grid_2"><label>Color:</label></div>
													<div class="grid_10">
														<div class="block_content">
															<input class="color"  type="text" name="color2" id="color2" class="i-format" required="required" onchange="return changeColorRuta();" value="FF3729"/>
														</div>
													</div>
													<div class="clear"></div>
												</section>												
																							
												
												<section class="form_row">
												<div class="grid_10 alignright">
														<div class="block_content">
															<button id="regRuta" class="button blue medium alignleft" >
																Registrar
															</button>
															
															<button id="modRuta" class="button red medium alignleft">
																Modificar
															</button>
																														
														</div>
												</div>
													<div class="clear"></div>
												</section>
											</form>
											</td>
										</tr>
										</table>	
									
								
									</div>
								</div>
							</div>
						</div>
					</div><!-- End of grid_12 -->
					<div class="clear"></div>
					
					
				</section><!-- end of #page_content -->
			</section><!-- end of #container_12 -->
		</section><!-- end of #container -->
		
	<script src="../js/ui_calls.js" type="text/javascript"></script>
	<script src="../js/scripts.js" type="text/javascript"></script>
	
		
	</body>

</html>